package com.vma.tools;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by chenzui on 2017/5/6.
 */
public class ReturnsUtil {



    /**

     * 处理成功返回协议对象

     * @param  data

     * @return

     */
    public static Map returnSuccess(Object data){
        Map<String, Object> jsonMap = new HashMap<String, Object>();
        jsonMap.put("resultCode","0");
        jsonMap.put("resultMsg","处理成功!");
        jsonMap.put("data", data);
        System.out.println(jsonMap);
        return jsonMap;
    }

    public static Map returnFail(Object data, String code){
        Map<String, Object> jsonMap = new HashMap<String, Object>();
        jsonMap.put("resultCode",code);
        jsonMap.put("resultMsg",data);
        jsonMap.put("data", "");
        System.out.println(jsonMap);
        return jsonMap;
    }


    public static Map<String, Object> returnException(String msg, Exception e){
        Map<String, Object> jsonMap = new HashMap<String, Object>();
        jsonMap.put("resultCode","-9997");
        jsonMap.put("resultMsg",msg);
        jsonMap.put("data", e.getMessage());
        System.out.println(jsonMap);
        return jsonMap;
    }

}
